unit Map_Config;

interface

uses
  SysUtils, Classes, XMLDoc, XMLIntf, DataEngine, Class_Config, Graphics;

type
  TMap_Config = class(TDataEngine)
  public
    function FuncXML_GetNodeName: string; override; 
    function FuncXML_GetNodeKey(ABaseClass: TBaseClass): string; override;
    procedure FuncXML_AddChildren(NodeA: IXMLNode; ABaseClass: TBaseClass); override;
    function FuncXML_ReadNode(NodeA: IXMLNode): TBaseClass; override;
  end;

implementation

{ TMap_Config }

procedure TMap_Config.FuncXML_AddChildren(NodeA: IXMLNode;
  ABaseClass: TBaseClass);
begin
  with TConfig(ABaseClass) do
  begin
    NodeA.Attributes['ID'] := ID;
    NodeA.Attributes['ErrorColor'] := ErrorColor; 
    NodeA.Attributes['ErrorFontColor'] := ErrorFontColor;
    NodeA.Attributes['BackgroundColor'] := BackgroundColor;
    if ShowSame then
    begin
      NodeA.Attributes['ShowSame'] := '1';
    end else
    begin
      NodeA.Attributes['ShowSame'] := '0';
    end;
    NodeA.Attributes['KMXJLL'] := KMXJLL;
  end;
end;

function TMap_Config.FuncXML_GetNodeKey(ABaseClass: TBaseClass): string;
begin
  Result := IntToStr(TConfig(ABaseClass).ID);
end;

function TMap_Config.FuncXML_GetNodeName: string;
begin
  Result := TConfig.ClassName;
end;

function TMap_Config.FuncXML_ReadNode(NodeA: IXMLNode): TBaseClass;
begin
  Result := TConfig.Create;
  with TConfig(Result) do
  begin
    ID := StrToInt(NodeA.Attributes['ID']);
    if NodeA.HasAttribute('ErrorColor') then
    begin
      ErrorColor := StrToInt(NodeA.Attributes['ErrorColor']);
    end else
    begin 
      ErrorColor := clRed;
    end;
    if NodeA.HasAttribute('ErrorFontColor') then
    begin
      ErrorFontColor := StrToInt(NodeA.Attributes['ErrorFontColor']);
    end else
    begin
      ErrorFontColor := clRed;
    end;
    if NodeA.HasAttribute('BackgroundColor') then
    begin
      BackgroundColor := StrToInt(NodeA.Attributes['BackgroundColor']);
    end else
    begin
      BackgroundColor := clLtGray;
    end;
    if NodeA.Attributes['ShowSame'] = '1' then
    begin
      ShowSame := True;
    end else
    begin
      ShowSame := False;
    end;
    if NodeA.HasAttribute('KMXJLL') then
    begin
      KMXJLL := NodeA.Attributes['KMXJLL'];
    end else
    begin 
      KMXJLL := '';
    end;
  end;
end;

end.
